  package cn.ekuma.android.ui.adapter;

import cn.ekuma.epos.ui.android.R;
import android.content.Context;
import android.view.View;
import android.view.ViewGroup;
import android.view.ViewGroup.LayoutParams;
import android.widget.BaseAdapter;
import android.widget.GridView;
import android.widget.ImageView;

public class InputViewAdapter extends BaseAdapter
{
	// ����Context
	private Context		mContext;
	// ������������ ��ͼƬԴ
	private Integer[]	mImageIds	= 
	{  R.drawable.btn1,
			R.drawable.btn2,
			R.drawable.btn3,
			R.drawable.btn4,
			R.drawable.btn5,
			R.drawable.btn6,
			R.drawable.btn7,
			R.drawable.btn8,
			R.drawable.btn9,
			R.drawable.btn0,
			R.drawable.btnminus,
			R.drawable.btndot
	};
	
	private String[]	mChars	= 
	{ 
			"1",
			"2",
			"3",
			"4",
			"5",
			"6",
			"7",
			"8",
			"9",
			"0",
			"00",
			"."
	};
	
	GridView mGv;   
    public static int ROW_NUMBER = 5;

	public InputViewAdapter(Context c,GridView gv)
	{
		mContext = c;
		this.mGv = gv;
	}

	// ��ȡͼƬ�ĸ���
	public int getCount()
	{
		return mImageIds.length;
	}

	// ��ȡͼƬ�ڿ��е�λ��
	public Object getItem(int position)
	{
		return position;
	}


	// ��ȡͼƬID
	public long getItemId(int position)
	{
		return position;
	}


	public View getView(int position, View convertView, ViewGroup parent)
	{
		ImageView imageView;
		if (convertView == null)
		{
			// ��ImageView������Դ
			imageView = new ImageView(mContext);
			// ���ò��� ͼƬ120��120��ʾ
			imageView.setLayoutParams(new GridView.LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT));
			// ������ʾ��������
			imageView.setScaleType(ImageView.ScaleType.FIT_CENTER);
			
			imageView.setPadding(8,8,8,8);
		}
		else
		{
			imageView = (ImageView) convertView;
		}

		imageView.setImageResource(mImageIds[position]);
		
		return imageView;
		
		
		
		
	}

	public String getcTran(int position) {
		return mChars[position];
	}

}
